/*
 * @Description: 全局注册Vue.$http 和 Vue.axios
 * @Author: wangfuwei
 * @Date: 2020-11-30 18:31:23
 * @LastEditors: wangfuwei
 * @LastEditTime: 2021-04-22 22:01:24
 * @FilePath: /horizon-frontend/src/utils/axios.js
 */
const VueAxios = {
  install(Vue, instance) {
    if (this.installed) {
      return;
    }
    this.installed = true;

    if (!instance) {
      console.error("You have to install axios");
      return;
    }

    Vue.axios = instance;

    Object.defineProperties(Vue.prototype, {
      axios: {
        get: function get() {
          return instance;
        },
      },
      $http: {
        get: function get() {
          return instance;
        },
      },
    });
  },
};

export { VueAxios };
